package com.ruoyi.train.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.train.domain.StudentInformation;
import com.ruoyi.train.domain.Vo.StudentInformationVo;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.ruoyi.train.service.IexamStudentInformationService;


/**
 * 学员信息Controller
 * 
 * @author wusihao
 * @date 2023-03-31
 */
@CrossOrigin
@Api(tags = "考试申请表学生信息", value = "接口")
@RestController
@RequestMapping("/student/examInformation")
public class examStudentInformationController extends BaseController
{
    @Autowired
    private IexamStudentInformationService examStudentInformationService;

    /**
     * 通过考试申请表id查找学生信息
     */
    @ApiOperation("通过考试申请表id查找学生信息")
    @Log(title = "提交考试申请", businessType = BusinessType.DELETE)
    @GetMapping("/list/{applicationId}")
    public AjaxResult getStudentInfoByExamApplicationId(@PathVariable Long applicationId)
    {
        List<StudentInformationVo> studentInfoByExamApplicationId = examStudentInformationService.getAllStudentInfoByExamApplicationId(applicationId);
        return success(studentInfoByExamApplicationId);
    }

    /**
     * 导出学员信息列表
     */
    @ApiOperation("导出学员信息列表")
    @Log(title = "学员信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StudentInformation examStudentInformation)
    {
        List<StudentInformation> list = examStudentInformationService.selectexamStudentInformationList(examStudentInformation);
        ExcelUtil<StudentInformation> util = new ExcelUtil<StudentInformation>(StudentInformation.class);
        util.exportExcel(response, list, "学员信息数据");
    }

    /**
     * 获取学员信息详细信息
     */
    @ApiOperation("获取学员信息详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(examStudentInformationService.selectexamStudentInformationById(id));
    }

    /**
     * 新增学员信息
     */
    @ApiOperation("新增学员信息")
    @Log(title = "学员信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StudentInformation examStudentInformation)
    {
        return toAjax(examStudentInformationService.insertexamStudentInformation(examStudentInformation));
    }

    /**
     * 修改学员信息
     */
    @ApiOperation("修改学员信息")
    @Log(title = "学员信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StudentInformationVo studentInformationVo)
    {
        int rows = examStudentInformationService.updateshenqingcailiaoxiangshuInformation(studentInformationVo);
        return toAjax(rows);
    }

    /**
     * 删除学员信息
     */
    @ApiOperation("删除学员信息")
    @Log(title = "学员信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(examStudentInformationService.deleteexamStudentInformationByIds(ids));
    }

    /**
     * 选中选中的学生信息提交进考试申请表
     */
    @ApiOperation("选中选中的学生信息提交")
    @Log(title = "选中选中的学生信息提交", businessType = BusinessType.UPDATE)
    @GetMapping("/selectStudent/{ids}")
    public AjaxResult selectStudent(@PathVariable Long[] ids)
    {
        return toAjax(examStudentInformationService.selectStudentPassExamApplication(ids));
    }

}
